package com.xigua.multithreading;

import java.util.List;

/**
 * @author LiRongHua
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2021/12/2222:17
 */
public class BaoZiPu extends Thread {

    private List<String> list;

    public BaoZiPu(String name, List<String> list) {
        super(name);
        this.list = list;
    }

    @Override
    public void run() {
        int i = 0;
        while (true) {
            synchronized (list) {
                if (list.size()>0){
                    try {
                        list.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                list.add("包子"+i++);
                System.out.println(list);
                list.notify();
            }
        }
    }



}
